StringRegexValidator Annotation

StringRegexValidator checks that a given String field, if not empty, matches the configured regular expression.

Usage

The annotation must be applied at method level.

Parameters

Parameter Required Default Notes
message yes   field error message
key no   i18n key from language specific properties file.
fieldName no    
shortCircuit no false If this validator should be used as shortCircuit.
type yes ValidatorType.FIELD Enum value from ValidatorType. Either FIELD or SIMPLE can be used here.
regex yes "." String property. The Regular Expression for which to check a match.
caseSensitive no true Whether the matching of alpha characters in the expression should be done case-sensitively.

Examples

@StringRegexValidator(message = "Default message", key = "i18n.key", shortCircuit = true, regex = "a regular expression", caseSensitive = true)